IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[cms_sp_PageWorkflowNotesSelectAll]') AND type in (N'P', N'PC'))
	DROP PROCEDURE [dbo].[cms_sp_PageWorkflowNotesSelectAll]
GO
create procedure [dbo].[cms_sp_PageWorkflowNotesSelectAll]
(
@PageId int,
@SiteGroupId int = null,
@SiteId int = null,
@SystemLanguageId int = null,
@PageTypeParameter nvarchar(400)
)
as
declare @PublicPageId int
select
	@PublicPageId = PublicPageId
from dbo.Pages
where PageId = @PageId
select 
	Workflows.WorkflowId,
	Workflows.CreatedBy,
	Workflows.DateCreated,
	Workflows.LastUpdatedBy,
	Workflows.DateLastUpdated
from dbo.Workflows
inner join dbo.EntityRevisions
on Workflows.WorkflowId = EntityRevisions.WorkflowId
where PublicEntityId = @PublicPageId and EntityTypeParameter = @PageTypeParameter
order by Workflows.DateCreated desc


GO

